package org.codeart.api_driver.service;

import org.codeart.api_driver.remote.ServiceDriverUserClient;
import org.codeart.common.dto.DriverCarBindingRelationship;
import org.codeart.common.dto.DriverUser;
import org.codeart.common.dto.DriverUserWorkStatus;
import org.codeart.common.util.HttpStatus;
import org.codeart.common.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {

    @Autowired
    private ServiceDriverUserClient serviceDriverUserClient;

    public boolean updateUser(DriverUser driverUser) {
        R<Void> r = serviceDriverUserClient.updateUser(driverUser);
        return r != null;
    }

    public boolean changeWorkStatus(DriverUserWorkStatus driverUserWorkStatus) {
        R<Void> r = serviceDriverUserClient.changeWorkStatus(driverUserWorkStatus);
        return r.getCode() == HttpStatus.HTTP_OK;
    }

    public R<DriverCarBindingRelationship> getDriverCarBindingRelationship(String driverPhone) {
        // 根据driverPhone查询司机信息
        return serviceDriverUserClient.getDriverCarRelationShip(driverPhone);

    }

    public R<DriverUserWorkStatus> getWorkStatus(Long driverId) {
        return serviceDriverUserClient.getWorkStatus(driverId);
    }
}
